package com.baoyi.utils;

import java.io.IOException;
import java.lang.reflect.Field;

import com.baoyi.domain.Pic;
import com.baoyi.utils.Connection.Method;

public class ConnectionApps {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Pic pic=new Pic();
		pic.setId("陈联高");
		Connection con = HttpConnection
				.connect("http://www.xabaoyi.com:8080/picweb/VoteServlet/");
		try {
			Class c = pic.getClass();
			Field[] fs = c.getDeclaredFields();
			for (int i = 0; i < fs.length; i++) {
				Field item = fs[i];
				item.setAccessible(true);
				Object value=item.get(pic);
				if(null!=value){
					con.data(item.getName(), value.toString());
				}
				
			}
			con.request().method(Method.POST);
			System.out.println(con.execute().body());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
